#
# written by Pavel C <pavelch+dcbot@gmail.com>
# src site: https://code.google.com/p/dc-bot/
#echo off
#cd inter
#set PYTHONDIR=c:\Python27\
. /ffp/etc/ffp.subr
MOUNTP=/mnt/usb
path1=/ffp/lib
#PATH=/opt/bin:$PATH
export PYTHONPATH=$path1/pyDClib27:$path1/pyDClib27/he3
#PYTHONSTARTUP=$path1/botDC.py
mkdir -p $MOUNTP/data/bot/log
name="python2_7"
python2_7_flags="-O -OO /ffp/bin/botDC.py $MOUNTP/data/bot/settings $MOUNTP/data/bot/log"
command="/opt/bin/python2_7"
_su="su nobody"
required_files="/ffp/bin/botDC.py"
start_cmd="dcbot_start_bg" 

dcbot_start_bg()
{
	_cmd="python2_7"
       eval _flags=\$$(echo $_cmd | tr '.-' '_')_flags 
	mkdir -p /ffp/var/log
        _log=/ffp/var/log/$(echo $name).log 
        _pids=$(find_pids $_cmd)
        if test -z "$_pids"; then
            test -x "$command"     || die "$1: Not executable"
            echo $PYTHONPATH
            echo "Starting $_su $command $_flags"
            su - nobody -c "export PYTHONPATH=$PYTHONPATH;$command $_flags 1>$_log 2>&1 </dev/null &"
        else
            warn "$_cmd: Already running"
        fi
        shift 1
    
    
} 
run_rc_command "$1"
 

